package com.xique.client.service.biz.service.impl;

import com.alibaba.fastjson.JSON;
import com.xique.client.api.IClientApi;
import com.xique.client.bean.request.ClientInOutRecordRequest;
import com.xique.client.bean.request.ClientMultCarListRequest;
import com.xique.client.bean.request.ClientParkOnListRequest;
import com.xique.client.service.biz.service.IClientRecordBizService;
import com.xique.common.core.utils.SecurityUtils;
import com.xique.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author shd
 * @create 2021/7/29 9:13
 */
@Service
public class ClientRecordBizServiceImpl implements IClientRecordBizService {

    @Autowired
    private IClientApi clientApi;

    /**
     * 在场列表
     * @author shd
     * @date 2021/7/29 9:14
     * @param request
     * @return com.xique.common.core.web.domain.AjaxResult
     */
    @Override
    public AjaxResult getParkOnList(ClientParkOnListRequest request) {

        request.setClientId(SecurityUtils.getClientId().toString());
        request.setOrderByColumn("pko.in_time");
        request.setIsAsc("desc");
        Map map = JSON.parseObject(JSON.toJSONString(request), Map.class);

        return new AjaxResult(clientApi.getParkOnList(map));
    }

    @Override
    public AjaxResult getMultCarList(ClientMultCarListRequest request) {
        request.setParkId( SecurityUtils.getParkId());
        request.setOrderByColumn("id");
        request.setIsAsc("desc");
        Map map = JSON.parseObject(JSON.toJSONString(request), Map.class);
        return new AjaxResult(clientApi.multCarList(map));
    }

    @Override
    public AjaxResult getclientInOnList(ClientInOutRecordRequest request) {
        request.setClientId(String.valueOf(SecurityUtils.getClientId()));
        request.setOrderByColumn("id");
        request.setIsAsc("desc");
        Map map = JSON.parseObject(JSON.toJSONString(request), Map.class);
        return  new AjaxResult(clientApi.inOutList(map));
    }
}
